import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author caoxiaofeng
 * @date 2021-03-16 08:51
 */
public class MybatisDemo {

    public static void main(String[] args) throws IOException {
        String resource = "mybatis-config.xml";
        // 读取配置文件
        InputStream inputStream = Resources.getResourceAsStream(resource);
        // 解析配置文件信息,并放到sqlSessionFactory 中
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

       SqlSession session = sqlSessionFactory.openSession();
       Student student = (Student) session.selectOne("StudentMapper.queryById", 1);
       System.out.println(student);

    }
}
